package org.gnyxy.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.gnyxy.dto.MaterialDTO;
import org.gnyxy.dto.MaterialPageQueryDTO;
import org.gnyxy.entity.Material;
import org.gnyxy.vo.MaterialVO;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface MaterialMapper {
    @Insert("insert into dish_material (name, default_number, image,recommended, price,unit, default_price, `range`, status, deleted)"+
    "values (#{name},#{defaultNumber},#{image},#{recommended},#{price},#{unit},#{defaultPrice},#{range},#{status},#{deleted})")
    void insert(MaterialDTO materialDTO);

    Page<MaterialVO> pageQuery(MaterialPageQueryDTO materialPageQueryDTO);

    void update(MaterialDTO materialDTO);

    @Select("select * from dish_material where deleted = 0 and id = #{id}")
    MaterialVO getById(Long id);

    @Select("select * from dish_material where deleted = 0 and status = 1 and id = #{id}")
    Material getStatusTrueById(Long materialId);

    List<Material> getTrueStatus(String name);

    List<BigDecimal> getStatusTrueByIds(List<Long> materialIds);

    @Select("select * from dish_material where deleted = 0 and status = 1")
    List<Material> getAll();

    @Select("select name from dish_material where id = #{id} and deleted = 0 and status = 1")
    String getNameById(Long id);

    List<Material> getByIds(List<Long> materialIds);
    @Select("select * from dish_material where deleted = 0 and id = #{id}")
    Material getMaterialById(Long materialId);
}
